#include <stdlib.h>
#include <stdio.h>

typedef struct {
  int     at_end; //boolean, says if it's EOF or not
  int     file_size; //size of file
  int     block_size; //size of packet
  int     block_number; //where we are in the file, != sequence number
  FILE *  file;
  char *  buffer;
} FileReader;

/**
 * Opens file, gets its size, saves relevant data to FileReader instance 
 * passed in parameters
 * 
 */
void initializeAndOpen(FileReader * reader, char * filename, int block_size);
/**
 * Reads file from current position, puts in packet
 * @param current instance of FileReader 
 * @return bytes read
 */
int readBlock(FileReader * reader);
/**
 * in case of retransmissions/receiving REJ/other errors
 * @param current instance of FileReader 
 * @return bytes read
 */
int readPreviousBlock(FileReader * reader);
/**
 * closes file
 * @param instane of FileReader
 */
void closeReader(FileReader * reader);
